<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta charset="utf-8">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="intranet Quality Monitoring">
        <meta name="author" content="Nader Hassan">
        <link rel="icon" href="img/favicon.ico">
        <title>Quality Monitoring | Dashboard</title>
        <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
        <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
        <link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
        <!-- Morris chart -->
        <link href="css/morris/morris.css" rel="stylesheet" type="text/css" />
        <!-- jvectormap -->
        <link href="css/jvectormap/jquery-jvectormap-1.2.2.css" rel="stylesheet" type="text/css" />
        <!-- Date Picker -->
        <link href="css/datepicker/datepicker3.css" rel="stylesheet" type="text/css" />
        <!-- Daterange picker -->
        <link href="css/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
        <!-- iCheck for checkboxes and radio inputs -->
        <link href="css/iCheck/all.css" rel="stylesheet" type="text/css" />
        <!-- bootstrap wysihtml5 - text editor -->
        <link href="css/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css" rel="stylesheet" type="text/css" />
        <!-- Theme style -->
        <link href="css/AdminLTE.css" rel="stylesheet" type="text/css" />
        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
          <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->
    </head>
    <?php
        require_once('Class/session.Class.php');
        require_once('header_redirection.php');
        require_once('Class/language.Class.php');
        require_once('Class/notification.Class.php');
        require_once('Class/connexionDB.Class.php');

        $translate     = new language();
        $session       = session::getInstance();
        $db            = new connexionDB();

        if (isset($_GET['lang']))
        {
            $session->lang      = strtoupper($_GET['lang']);
        }
        $translate->changeLanguage($session->lang);
        /*var_dump($_SESSION);*/

        //variables to select the good category
        $home           = '';
        $reporting      = '';
        $newRating      = '';
        $admin          = '';
        $profil         = '';
        $mail           = '';
        $tran           = '';
        $weeklyReport   = '';

        $path_parts = pathinfo($_SERVER['PHP_SELF']);

        if (isset($path_parts['filename']) && $path_parts['filename'] == 'home')
        {
            $home = 'active';
        }
        else if (isset($path_parts['filename']) && $path_parts['filename'] == 'administration')
        {
            $admin = 'active';
        }
        else if (isset($path_parts['filename']) && ($path_parts['filename'] == 'new_rating' 
                    || $path_parts['filename'] == 'create_new_rating' 
                    || $path_parts['filename'] == 'search'
                    || $path_parts['filename'] == 'show_rating')
                    || $path_parts['filename'] == 'calibration'
                    || $path_parts['filename'] == 'edit_evaluation') 
        {
            $newRating = 'active';
        }
        else if (isset($path_parts['filename']) && $path_parts['filename'] == 'reporting')
        {
            $reporting = 'active';
        }
        else if (isset($path_parts['filename']) && $path_parts['filename'] == 'profil')
        {
            $profil = 'active';
        }
        else if (isset($path_parts['filename']) && $path_parts['filename'] == 'mail')
        {
            $mail = 'active';
        }
        else if (isset($path_parts['filename']) && $path_parts['filename'] == 'upload_translate')
        {
            $tran = 'active';
        }
        else if (isset($path_parts['filename']) && $path_parts['filename'] == 'weekly_report')
        {
            $weeklyReport = 'active';
        }

        // Get Notification 
        $notif          = new notification();

        $groups = $db->getGroupByIdAccount($session->id_account);

        if (isset($groups[0]['id_groups']))
        {
            $session->group = $groups[0]['id_groups'];
        }

        $listedNotif    = $notif->getRatingForNotification($session->id_account, $session->id_accountType, $session->group);
        $nb_rating      = 0;

        foreach ($listedNotif as $value)
        {
            $nb_rating += count($value);
        }
    ?>
    <body class="skin-blue">
        <!-- header logo: style can be found in header.less -->
        <header class="header">
            <a href="reporting.php" class="logo">
                <!-- Add the class icon to your logo image or logo icon to add the margining -->
                Quality Monitoring
            </a>
            <!-- Header Navbar: style can be found in header.less -->
            <nav class="navbar navbar-static-top" role="navigation">
                <!-- Sidebar toggle button-->
                <a href="#" class="navbar-btn sidebar-toggle" data-toggle="offcanvas" role="button">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </a>
                <div class="navbar-right">

                    <ul class="nav navbar-nav">
                        <?php 
                            // GET LIST TRADUCTION FILE
                            $files = $db->getFilePath();
                            /*var_dump($files);*/

                        ?>
                        <?php foreach ($files as $value) : ?>
                            <?php $lang = strtolower($value['name']); ?>
                            <li>
                                <div id="frenchFlag" width="30px" style="color:white;margin:10px;cursor: pointer" onclick="javascript:location.href='reporting.php?lang=<?php echo $lang; ?>'"><?php echo $value['name']; ?></div>
                            </li>
                        <?php endforeach; ?>
                        <!-- <li>
                            <div id="englishFlag" width="30px" style="color:white;margin:10px;cursor: pointer" onclick="javascript:location.href='home.php?lang=en'"/>EN</div>
                        </li> -->
                        <!-- Tasks: style can be found in dropdown.less -->
                        <li class="dropdown tasks-menu">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                <i class="fa fa-tasks"></i>
                                <?php if ($nb_rating != 0) : ?>
                                    <span style="width:20px;" class="label label-danger"><?php echo $nb_rating; ?></span>
                                <?php endif; ?>
                            </a>
                            <ul class="dropdown-menu">
                                <li class="header"><?php echo $translate->translate('workflow') . ' : '. $nb_rating . ' ' . $translate->translate('notificationSmall'); ?></li>
                                <li>
                                    <!-- inner menu: contains the actual data -->
                                    <ul class="menu">
                                        <?php foreach ($listedNotif as $notif) : ?>
                                            <?php foreach ($notif as $value) : ?>
                                                <li><!-- Task item -->
                                                    <a href="<?php echo 'show_rating.php?id=' . $value['id'];?>">
                                                        <h3>
                                                            <?php 
                                                                $progress = $value['progress'];
                                                                echo '#' . $value['id'] . ' par ' . $value['name_rater'] . ' le ' . $value['date_eval']; ?>
                                                            <small class="pull-right"><?php echo $progress; ?>%</small>
                                                        </h3>
                                                        <div class="progress xs">
                                                            <div class="progress-bar progress-bar-aqua" style="width: <?php echo $progress; ?>%" role="progressbar" aria-valuenow="<?php echo $progress; ?>" aria-valuemin="0" aria-valuemax="100">
                                                                <span class="sr-only"><?php echo $progress; ?>%</span>
                                                            </div>
                                                        </div>
                                                    </a>
                                                </li><!-- end task item -->
                                            <?php endforeach; ?>
                                        <?php endforeach; ?>
                                    </ul>
                                </li>
                            </ul>
                        </li>
                        <li class="dropdown user user-menu">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                <i class="glyphicon glyphicon-user"></i>
                                <span> <?php echo ucfirst($session->firstname) . ' '  . ucfirst($session->lastname);?> <i class="caret"></i></span>
                            </a>
                            <ul class="dropdown-menu">
                                <!-- User image -->
                                <li class="user-header bg-light-blue">
                                    <img src="img/avatar5.png" class="img-circle" alt="User Image" />
                                    <p>
                                        <?php echo ucfirst($session->firstname) . ' '  . ucfirst($session->lastname) . ' - ' . ucfirst($session->name_accountType);?> 
                                    </p>
                                </li>
                                <!-- Menu Footer-->
                                <li class="user-footer">
                                    <!-- <div class="pull-left">
                                        <a href="#" class="btn btn-default btn-flat"><?php echo $translate->translate('HomePageProfil'); ?></a>
                                    </div> -->
                                    <div class="pull-right">
                                        <a href="logout.php" class="btn btn-default btn-flat"><?php echo $translate->translate('HomePageLougOut'); ?></a>
                                    </div>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </nav>
        </header>
        <div class="wrapper row-offcanvas row-offcanvas-left">
            <!-- Left side column. contains the logo and sidebar -->
            <aside class="left-side sidebar-offcanvas">
                <!-- sidebar: style can be found in sidebar.less -->
                <section class="sidebar">
                    <!-- Sidebar user panel -->
                    <div class="user-panel">
                        <div class="pull-left image">
                            <img src="img/avatar5.png" class="img-circle" alt="User Image" />
                        </div>
                        <div class="pull-left info">
                            <p>Hello,  <?php echo ucfirst($session->firstname);?></p>
                        </div>
                    </div>
                    <!-- sidebar menu: : style can be found in sidebar.less -->
                    <ul class="sidebar-menu">
                        <!-- <li class="<?php echo $home; ?>">
                            <a href="home.php">
                                <i class="fa fa-dashboard"></i> <span><?php echo $translate->translate('HomePage'); ?></span>
                            </a>
                        </li> -->
                        <li class="treeview <?php echo $newRating; ?>">
                            <a href="#">
                                <i class="fa fa-edit"></i> <span><?php echo $translate->translate('HomePageRating'); ?></span>
                                <i class="fa fa-angle-left pull-right"></i>
                            </a>
                            <ul class="treeview-menu">
                                <li><a href="calibration.php"><i class="fa fa-angle-double-right"></i> <?php echo $translate->translate('Calibration'); ?></a></li>
                                <li><a href="new_rating.php"><i class="fa fa-angle-double-right"></i> <?php echo $translate->translate('NewRating'); ?></a></li>
                                <li><a href="search.php"><i class="fa fa-angle-double-right"></i> <?php echo $translate->translate('SearchRating'); ?></a></li>
                                <?php if ($session->id_accountType != 2) : ?>
                                    <li><a href="create_new_rating.php"><i class="fa fa-angle-double-right"></i> <?php echo $translate->translate('CreateRating'); ?></a></li>
                                    <li><a href="edit_evaluation.php"><i class="fa fa-angle-double-right"></i> <span><?php echo $translate->translate('editRating'); ?></span></a></li>
                                <?php endif; ?>
                            </ul>
                        </li>
                        
                        <li class="<?php echo $reporting; ?>">
                            <a href="reporting.php">
                                <i class="fa fa-bar-chart-o"></i> <span><?php echo $translate->translate('ReportTitle'); ?></span>
                            </a>
                        </li>
                        <!-- <li class="<?php echo $profil; ?>">
                            <a href="profil.php">
                                <i class="fa fa-cogs"></i> <span><?php echo $translate->translate('profil'); ?></span>
                            </a>
                        </li> -->
                        <li class="<?php echo $weeklyReport; ?>">
                            <a href="weekly_report.php">
                                <i class="fa fa-calendar"></i> <span><?php echo $translate->translate('weeklyReport'); ?></span>
                            </a>
                        </li>
                        <?php if (isset($session->name_accountType) && $session->name_accountType == "admin") : ?>
                            <li class="<?php echo $mail; ?>">
                                <a href="mail.php">
                                    <i class="fa fa-envelope"></i> <span><?php echo $translate->translate('mail'); ?></span>
                                </a>
                            </li>
                        <?php endif; ?>
                        <?php if (isset($session->name_accountType) && $session->name_accountType == "admin") : ?>
                            <li class="<?php echo $tran; ?>">
                                <a href="upload_translate.php">
                                    <i class="fa fa-folder"></i> <span><?php echo $translate->translate('translate'); ?></span>
                                </a>
                            </li>
                        <?php endif; ?>
                        <?php if (isset($session->name_accountType) && $session->name_accountType == "admin") : ?>
                            <li class="<?php echo $admin; ?>">
                                <a href="administration.php">
                                    <i class="glyphicon glyphicon-wrench"></i> <span><?php echo $translate->translate('HomePageAdministration'); ?></span>
                                </a>
                            </li>
                        <?php endif ?>
                    </ul>
                </section>
                <!-- /.sidebar -->
            </aside>